//
//  ZXLNetWorking.h
//  ZXLSign
//
//  Created by zxl02 on 2020/11/10.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN
typedef void (^SuccessBlock)(NSDictionary *responseObject);
typedef void (^FailureBlock)(NSError *error);
typedef void (^ProgressBlock)(NSProgress *progress);
@interface ZXLNetWorking : NSObject
@property (nonatomic, copy) SuccessBlock successBlock;
@property (nonatomic, copy) FailureBlock failureBlock;
/**
 *  发送get请求
 *
 *  @param URLString  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 */
+ (NSURLSessionDataTask *)getWithURLString:(NSString *)urlString
                                parameters:(id)parameters
                                   success:(SuccessBlock)successBlock
                                   failure:(FailureBlock)failureBlock;
/**
 *  发送post请求
 *
 *  @param URLString  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 */
+ (NSURLSessionDataTask *)postWithURLString:(NSString *)urlString
                                 parameters:(id)parameters
                                    success:(SuccessBlock)successBlock
                                    failure:(FailureBlock)failureBlock;

+ (NSURLSessionDataTask *)requestWithURLString:(NSString *)urlString
                                    httpMethod:(NSString *)httpMethod
                                      httpBody:(NSData *)httpBody
                                       success:(SuccessBlock)successBlock
                                       failure:(FailureBlock)failureBlock;


/**
 *  发送delete请求
 *
 *  @param URLString  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 */
+ (NSURLSessionDataTask *)deleteWithURLString:(NSString *)urlString
                                   parameters:(id)parameters
                                      success:(SuccessBlock)successBlock
                                      failure:(FailureBlock)failureBlock;

/// 文件上传
/// @param name 表单文件参数名
/// @param fileName 文件名
/// @param mimeType 文件类型
/// @param parameters 其他参数
+ (NSURLSessionDataTask *)postFileWithURLString:(NSString *)urlString
                                       fileData:(NSData *)fileData
                                           name:(NSString *)name
                                       fileName:(NSString *)fileName
                                       mimeType:(NSString *)mimeType
                                     parameters:(id)parameters
                                       progress:(ProgressBlock)progressBlock
                                        success:(SuccessBlock)successBlock
                                        failure:(FailureBlock)failureBlock;
/**
 请求头加密算法
 
 @param time 时间戳
 @param random 10位数以内的随机数
 @return 加密字符串
 */
+ (NSString *)signature:(NSString *) time  AndRandom:(NSString *) random;

//获取当前时间戳
+ (NSString *)currentTimeStr;

//获取随机数
+ (NSString *)getArc4random;

//获取请求头参数
+ (NSDictionary *)getRequestHeaderParams;

//获取测试环境api地址
+ (NSString *)getDevApi:(NSString *)api;
//加签
+ (void)setV2SecurityHeader:(AFHTTPSessionManager*)manage url:(NSString*)url body:(NSDictionary*)body requestType:(NSString*)type;
@end

NS_ASSUME_NONNULL_END
